<?php
	require_once "includes/pagination.php";
	$itemPerPage=10;
	if($_SESSION['user_id_sess']=="") {
		echo "<script type='text/javascript'> window.location='index.php?signin&url=mylist'; </script>";
	}
	$userId = $_SESSION['user_id_sess'];
?>
<div id='panel'>
<table width="100%" border="0">
  <tr>
    <td class="contentHeader"><h2>Product Detail </h2></td>
  </tr>
  <tr>
    <td>		
      	 
		 <?php
		 	//delete single product		 
			if(!empty($_POST['hidDelPro'])) {
			
				$proId=$_POST['hidDelPro'];
				$sqlDelPro="Delete from tbl_wholeseller_product where product_id=$proId";
				$rstDelPro=mysql_query($sqlDelPro);
				if($rstDelPro) { 
					$imgPaths=getImagePath($proId);
					if($imgPaths[0]!="") { unlink($imgPaths[0]); }
					if($imgPaths[1]!="") { unlink($imgPaths[1]); }
					if($imgPaths[2]!="") { unlink($imgPaths[2]); }
					echo "<div id='suc-msg'> Your product deleted. </div><br>"; 
				}	
				else {
					echo "<div id='err-msg'> Your product could not be deleted. </div><br>";
				}
			}			
			   
		 ?>
		 <form name="frmProlist" id="frmProlist" method="post" action="">
		 	<input type="hidden" name="hidDelPro" id="hidDelPro">
		 <?php		   
				   $sqlSelPro="SELECT * FROM tbl_wholeseller_product where posted_by='$userId' and product_id='".$_REQUEST['whole_listing']."' ORDER BY product_id DESC";
				   $rstSelPro=mysql_query(getPagingQuery($sqlSelPro,$itemPerPage));				  
				   $num=mysql_num_rows($rstSelPro);
				   
				   if($num==0)
					{
					  echo "<div style='border-top:1px solid #CCCCCC;'> </div><br>";
					  echo "<p style='padding:5px;'>No items found on your list...</p><br>";
					  echo "<div style='border-top:1px solid #CCCCCC;'> </div><br>";
					}
				   else {	?>
				   		  <br><table width='100%' border='0' align='center' cellspacing='0'>
						  <tr class='head-tr'>
								  <td width="6%"><strong>S.No</strong></td>	
								  <td width="20%"><strong>Product Code</strong> </td>							
								  <td width="34%"> <strong>Product name </strong></td>
								  <td width="13%"> <strong> -- </strong></td>
								  <td width="14%"> <strong>Price</strong> </td>
							      
								  <td width="6%">&nbsp; </td>
								  <td width="7%">&nbsp; </td>
								</tr>				 
						 <?php
						 $r=1;
						 while($rowSelPro=mysql_fetch_array($rstSelPro))
					     {						   
						   $productCode=$rowSelPro['product_code'];
						   $productId=$rowSelPro['product_id'];
						   $productName=wordFormater($rowSelPro['product_name'],20);
						   $productTitle = $rowSelPro['product_name'];					   
						   $productPrice=$rowSelPro['product_price'];
						  
						   $postedDate=$rowSelPro['posted_date'];
						
						  // $timeLeft = getRemainingTime($bargainDate);
						   
						  
						   					   
						   echo "<tr>
						   		 <td height='28'> $r </td>							         
								 <td > $productCode </td>
								 <td > <a href='index.php?products=$productId' title='$productTitle'> $productName </a> </td>
								 <td > <input type='image' src='images/buy.gif' style='cursor:pointer;' onClick=''> </td>
								 <td > $$productPrice </td>
								 
						      	 <td><a href='index.php?editwholeitem=$productId'>Edit</a></td>
								 <td><a href='javascript:void(0);' onClick='funDelProduct('frmProlist','prod',$productId)'>Delete</a></td>
							   </tr>";	
							echo "<tr>
									 <td colspan='7'> <div style='border-top:1px solid #CCCCCC;'> </div> </td>
								  </tr>";   			  
						 	$r++;
						 } ?>
						</table>				    	
						<?php
					} 				
	?>
	
	</form>
	</td>
</tr>	

<tr>
	<td><div align="center"><?php
		   $link="mylist";
		   echo $disp=getPagingLink($sqlSelPro,$itemPerPage,$link);							   
	 ?></div>
	</td>
</tr>
</table>
</div>	

							
	